#include "lprintf.h"
#include "server.h"
#include <stdio.h>
#include <stdarg.h>
#include <time.h>
#include <unistd.h>

int lprintf(const char* fmt, ...)
{
     FILE* logs = stderr;	/* TODO: change this to srvconf.logs */

     char timebuf[32];
     time_t current = time(NULL);
     /* print current time */

     struct tm current_tm;
     localtime_r(&current, &current_tm);
     strftime(timebuf, sizeof(timebuf), "%b %d %H:%M:%S", &current_tm);
     
     fprintf(logs, "%s[%d]: ", timebuf, getpid());

     va_list args;
     va_start(args, fmt);
     int tmp = vfprintf(logs, fmt, args);
     va_end(args);

     return tmp;
}

